// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ApplicationListener.java

package cn.com.pusai.common.listener;

//import cn.com.ecinc.base.merge.model.Module;
//import cn.com.ecinc.base.module.service.ModuleService;
//import cn.com.ecinc.base.organization.service.OrganizationService;
//import cn.com.ecinc.common.config.MyProperties;
//import cn.com.ecinc.common.config.SysProperties;
//import cn.com.ecinc.common.util.SearchMap;
//import cn.com.ecinc.common.util.SpringUtil;
//import cn.com.ecinc.core.exception.ServiceException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ApplicationListener extends HttpServlet
	implements ServletContextListener
{

	protected Logger logger;

	public ApplicationListener()
	{
		logger = LoggerFactory.getLogger(getClass());
	}

	/**
	 * 销毁监听方法
	 * */
	public void contextDestroyed(ServletContextEvent ctxEvent)
	{
//		if (ctxEvent == null || ctxEvent.getServletContext() == null)
//			return;
//		Enumeration e = ctxEvent.getServletContext().getAttributeNames();
//		String key = "";
//		for (; e.hasMoreElements(); ctxEvent.getServletContext().removeAttribute(key))
//			key = (String)e.nextElement();
  
	}
	
	/**
	 * 初始化缓存数据
	 * */
	public void contextInitialized(ServletContextEvent ctxEvent){
		System.out.println("======初始化=====缓存数据方法========");
//		try
//		{
//			ModuleService moduleService = (ModuleService)SpringUtil.getBean("moduleService");
//			List moduleList = moduleService.findModules();
//			Map moduleMap = new HashMap();
//			Module module;
//			for (Iterator iterator = moduleList.iterator(); iterator.hasNext(); moduleMap.put(module.getCode(), module.getName()))
//				module = (Module)iterator.next();
//
//			ctxEvent.getServletContext().setAttribute("APP_DATA_MODULE_MAP", moduleMap);
//			boolean loadOrgData = SysProperties.Properties.getBooleanProperty("loadappdata.org", false);
//			if (loadOrgData)
//			{
//				OrganizationService orgService = (OrganizationService)SpringUtil.getBean("organizationService");
//				List orgList = orgService.findObjects(new SearchMap());
//				ctxEvent.getServletContext().setAttribute(SysProperties.ALL_ORG_LIST, orgList);
//			}
//		}
//		catch (ServiceException e)
//		{
//			logger.warn((new StringBuilder("加载模块数据失败： ")).append(e.getMessage()).toString());
//			e.printStackTrace();
//		}
	}
}
